<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <h3>Vue-反转字符串</h3>
        <div> {{ msg }} </div>
        <button @click="handleBtnClick">点击反转</button>
    </div>
    <script src="./js/vue.js"></script>
    <script>

        const vm = new Vue({
            el:'#app',
            // data必须是一个函数，return一个对象
            data(){
                return {
                    msg:'Hello World'
                }
            },
            methods: {
                handleBtnClick(){
                    // this.msg = 'dlroW olleH'
                    // 1. str.split('')
                    // this.msg = this.msg.split('').reverse().join('')

                    // 2. [...str] 展开字符串
                    // console.log([...this.msg])
                    this.msg = [...this.msg].reverse().join('')
                }
            }
        })
        // v-bind  ==> : 
        // v-on    ==> @
    </script>
</body>
</html>